<?php

    class LoginView {
      
	  	private $usernameInput = "usernameInput";
		private $passwordInput = "passwordInput";
		private $loginInput = "loginInput";
		private $logoutInput = "logoutInput";
		private $checkRemember = "checkRemember";
		
		// Function used to create the Login form.
		// Returns XHTML string
        public function DoLoginBox(){
        	
			return "
<div>
	<form method='get'>
		Username: <input type='text' name=$this->usernameInput></input><br/>
		Password: <input type='text' name=$this->passwordInput ></input><br/>
		<input type='submit' name=$this->loginInput value='Login'/>
		Remember me: <input type='checkbox' name=$this->checkRemember />
	</form>
</div>";
        }
		
		// Function used to create the Logout button.
		// Returns XHTML string
		public function DoLogoutBox(){
				
			return "<div>
	<form method='get'>
		<input type='submit' name=$this->logoutInput value='Logout'/>
	</form>
</div>";
		}
		
		// Function used to retrive a submitted username.
		// Returns a username if existing, otherwise null.
		public function GetUserName(){
			if (isset( $_GET[$this->usernameInput]) == true) {
				return $_GET[$this->usernameInput];
			}
			return null;
		}
		
		// Function used to retrive a submitted password.
		// Returns a password if existing, otherwise null.
		public function GetPassword(){
			if (isset( $_GET[$this->passwordInput]) == true) {
				return $_GET[$this->passwordInput];
			}
			return null;
		}
		
		// Function used to see if the login button have been pressed.
		// Returns true if the button have been pressed, otherwise false.
		public function TriedToLogIn(){
			if (isset( $_GET[$this->loginInput]) == true) {
				return true;
			}
			return false;
		}
		
		// Function used to see if the logout button have been pressed.
		// Returns true if the button have been pressed, otherwise false.
		public function TriedToLogOut(){
			if (isset( $_GET[$this->logoutInput]) == true) {
				return true;
			}
			return false;
		}
    }
      